<?php
/*
 * Aclass_stat 统计类
 * 2010-12-03
 * http://www.abans.cn		abans@qq.com
 */
class Aclass_stat{
	function  __construct() {
	}
	/*
	$datas[0]->pv = '0';
	$datas[0]->time = '2010-12-02 8:00';
	$datas[1]->pv = '4';
	$datas[1]->time = '2010-12-02 9:00';
	$datas[2]->pv = '17';
	$datas[2]->time = '2010-12-02 10:00';
	$datas[3]->pv = '0';
	$datas[3]->time = '2010-12-02 11:00';
	$datas[4]->pv = '0';
	$datas[4]->time = '2010-12-02 12:00';
	$datas[5]->pv = '13';
	$datas[5]->time = '2010-12-02 13:00';
	$datas[6]->pv = '0';
	$datas[6]->time = '2010-12-02 14:00';
	$tdata[0]->name='PV';
	$tdata[0]->color='0033CC';
	$tdata[0]->bordercolor='0033CC';
	$tdata[0]->data = $datas;

		$data->y = $tdata;
		$data->x = array('8:00','9:00','10:00','11:00','12:00','13:00','14:00');
		echo stat_xml($data);
	*/
	function data_html($data=''){
		if(empty($data->height)){$data->height = '220';}
		if(empty($data->width)){$data->width = '760';}
		if(empty($data->dataurl)){$data->dataurl = 'data.php';}
		$data->swf = '/plugins/flash/stat/stat.swf?ChartNoDataText=没有可显示的数据&PBarLoadingText=正在载入图表，请稍候&XMLLoadingText=正在获取数据，请稍候&ParsingDataText=正在读取数据，请稍候&RenderingChartText=正在渲染图表，请稍候&LoadDataErrorText=载入数据时发生错误&InvalidXMLText=数据错误';
		$html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'.$data->width.'" height="'.$data->height.'" id="MSLine">
<param name="movie" value="'.$data->swf.'"/>
<param name="FlashVars" value="&dataURL='.$data->dataurl.'"/>
<param name="quality" value="high"/>
<param name="wmode" value="transparent"/>
<embed src="'.$data->swf.'" flashvars="&dataURL='.$data->dataurl.'" quality="high" wmode="transparent" width="'.$data->width.'" height="'.$data->height.'" name="MSLine" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>';
		return $html;
	}
	function data_xml($data){
		$xml = "<chart showFCMenuItem='0' lineThickness='2' showValues='0' anchorRadius='4' divLineAlpha='20' divLineColor='CC3300' divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='5' alternateHGridColor='CC3300' shadowAlpha='40' labelStep='2' numvdivlines='25' showAlternateVGridColor='1' chartsshowShadow='1' chartRightMargin='20' chartTopMargin='15' chartLeftMargin='0' chartBottomMargin='3' bgColor='FFFFFF' canvasBorderThickness='1' showBorder='0' legendBorderAlpha='0' bgAngle='360' showlegend='1' borderColor='DEF3F3' toolTipBorderColor='cccc99' canvasPadding='0' toolTipBgColor='ffffcc' legendShadow='0' baseFontSize='12' canvasBorderAlpha='20' outCnvbaseFontSize='10' outCnvbaseFontColor='000000' numberScaleValue='10000,1,1,1000' formatNumberScale='1' palette='2' numberScaleUnit=' , ,万,千万' lineColor='AFD8F8'>";
	//数据（底线）
		$xml .="<categories>\n";
		foreach ($data->keys as $k => $v) {
			$xml .= "<category label='$k' />\n";
		}
		$xml .= "</categories>\n";
	//数据（线条）
		foreach ($data->y as $key => $val) {
			$xml .= "<dataset  seriesName='$val->name' color='$val->color' anchorBorderColor='$val->bordercolor'  >\n";
			foreach ($data->keys as $k => $v) {
				$value = $val->data[$k]->value;
				$xml .= "<set  value='".$value."' toolText='".$val->data[$k]->text."' />\n";
			}
			$xml .= "</dataset>\n";
		}
	//样式
		$xml .= "
	<styles>
		<definition>
			<style name='CaptionFont' type='font' size='12'  />
			<style name='myLegendFont' type='font' size='11'  />
		</definition>
		<application>
			<apply toObject='CAPTION' styles='CaptionFont'  />
			<apply toObject='SUBCAPTION' styles='CaptionFont'  />
			<apply toObject='Legend' styles='myLegendFont'  />
		</application>
	</styles>
	</chart>";
		return $xml;
	}

}

?>
